extensions: u32<->float conversions in simple extension
authorØyvind Kolås <pippin@gimp.org>
Sat, 7 Apr 2018 15:01:08 +0000 (17:01 +0200)
committerØyvind Kolås <pippin@gimp.org>
Sat, 7 Apr 2018 15:08:01 +0000 (17:08 +0200)
They were using 'float' rather than 'double' data types for intermediate values
the lack of precision made the conversions be discarded by babl.

extensions/simple.c

index 1d8e7501db86111aea7385f45406b5a73d102cfe..9bd5d826c68c4e6d9400688d88467c2c61ce87da 100644 (file)
@@ -168,7 +168,7 @@ float_to_u32_x1 (const Babl *conversion,unsigned char *src_char, unsigned char *
   long n = samples;
   while (n--)
     {
-      float r = src[0];
+      double r = src[0];
             
       dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFFFFFF * r + 0.5f);
       
@@ -201,7 +201,7 @@ u32_to_float (const Babl *conversion,unsigned char *src_char, unsigned char *dst
   long n = samples;
   while (n--)
     {
-      dst[0] = src[0] / 4294967295.0f;
+      dst[0] = src[0] / 4294967295.0;
       dst ++;
       src ++;
     }